export default {
    //更新token
    setToken(state, data) {
        const {
            mark,
            token,
            expire,
            actions
        } = data;
        state.token = token;
        uni.setStorageSync('token', token);
        uni.setStorageSync('expire', expire);
        uni.setStorageSync('mark', mark);
        uni.setStorageSync('action', actions);
  //       this.dispatch('getUserInfo');
		// this.dispatch('gettownList');
		
    },
    setUserInfo(state, data) {
        Object.assign(state.userInfo, payload);
    },
    //更新state数据
    setStateAttr(state, param) {
        if (param instanceof Array) {
            for (let item of param) {
                state[item.key] = item.val;
            }
        } else {
            state[param.key] = param.val;
        }
    },
	setTownList(state, param){
		
		state.townList = param.val
		
	},
    //退出登录
    logout(state) {
		state.isnurse = '';
        state.token = '';
        state.moduleActions = [];
		state.townList = [];
		uni.removeStorageSync('isnurse')
        uni.removeStorageSync('token');
        uni.removeStorageSync('expire');
        uni.removeStorageSync('mark');
        uni.removeStorageSync('action');
        setTimeout(() => {
            state.userInfo = {};
        }, 500)
    }
}
